<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .q1 {
            width: 100px;
            height: 100px;
            background-color: aqua;

            z-index: 1000;
        }

        .q2 {
            position: sticky;
            top: 10;
            transform: translateY(-100px);

            width: 100px;
            height: 100px;
            background-color: blue;
        }
    </style>
</head>

<body>
    <div class="q1">1</div>
    <div class="q2">2</div>
</body>
<script>
    let arrOld = [1, 2, 3, 2, 5, 1, 7, 9, 3]
    // 方法1
    function func(arr) {
        let arrNew = []
        for (let i = 0; i < arr.length; i++) {
            if (arrNew.indexOf(arr[i]) === -1) {
                arrNew.push(arr[i])
            }
        }
        return arrNew
    }

    // 方法2
    function fun(arr) {
        let arrNew = []
        let flag = true
        for (let i = 0; i < arr.length; i++) {
            flag = true
            for (let j = 0; j < arrNew.length; j++) {
                if (arr[i] === arrNew[j]) {
                    flag = false
                }
            }
            if (flag) {
                arrNew.push(arr[i])
            }
        }
        return arrNew
    }

    // 方法三
    function setFunc(arr){
        return [...new Set(arr)]
    }
    console.log(setFunc(arrOld));
</script>

</html>